package homework;

import java.util.Scanner;

/**
 * @author Ho sen ding
 * @Title: management
 * @Description: 管理
 * @date 2020/4/2110:56
 */
public class Management {
    public static void main(String[] args) {
        System.out.println("请输入课程数量:");
        Scanner courseNum =new Scanner(System.in);
        Course[] courses = new Course[courseNum.nextInt()];
        for (int i = 0;i<courses.length;i++){
            courses[i]=new Course();
            System.out.println("请输入课程名:");
            Scanner courseName=new Scanner(System.in);
            courses[i].setName(courseName.nextLine());
        }
        System.out.print("\n");
        System.out.print("请输入学生课程数量:");
        Scanner studentNum = new Scanner(System.in);
        Student[] students = new Student[studentNum.nextInt()];
        for(int i=0;i<students.length;i++){
            students[i]=new Student();
            System.out.println("请输入学生名:");
            Scanner studentName=new Scanner(System.in);
            students[i].setName(studentName.nextLine());
            System.out.print("\n");
            System.out.print("请输入学生选课数量，且该数量不得大于"+courses.length +":");
            Scanner chooseCourse = new Scanner(System.in);
            int choose = chooseCourse.nextInt();
            if(choose<=courses.length){
                System.out.print("\n");
                System.out.print("现在有这些课，请选择序号:");
                for(int j=0;j<courses.length;j++){
                    System.out.print(j+"."+courses[j].getName() +" ");
                }
                for(int ij=0;ij<choose;ij++){
                    System.out.print("\n");
                    System.out.print("第"+ij+"次，请选择序号:");
                    Scanner studentSelect =new Scanner(System.in);
                    int select =studentSelect.nextInt();
                    students[i].getCourses().add(courses[select].getName());
                    courses[select].getStudents().add(students[i].getName());
                }
            }
        }
        System.out.print("\n");
        System.out.print("");
    }
}
